export  default {
  name: 'site',
  namespaced: true,
  state: {
    // 定义一个地址数据
    siteList: [
      {
        name: 'HOPU',
        phone: '13515111568',
        shippingAddress: '湖北省武汉市洪山区华山街道软件新城B13栋',
        default: true
      }
    ],
  },
  getters: {
    listDefault(state) {
      let arr = [];
     return state.siteList.some((value) => {
         if (value.default){
           arr.push(value);
           if (arr.length > 1) {
             delete  value.default;
           }
         }
     });
    }
  },
  mutations: {
    remveList(state, index) {
       state.siteList.splice(index, 1);
    },
    pushList(state, value) {
      if (value.default === true) {
        state.siteList.unshift(value);
      } else {
        state.siteList.splice(1, 0, value);
      }
    }
  }
}
